<?php

namespace Home\Model;

use Think\Model;

class StoreModel extends Model {

    protected $tableName = 'store';

    function insert($data) {
        return $this->add($data);
    }

    function getList($where) {
        $page_size = 10;
        $count = $this->where($where)->count();
        $page = new \Think\Page($count, $page_size);
        $list = $this->where($where)->order('add_time desc')->limit($page->firstRow, $page_size)->select();
        $p = I('get.p', 1, 'intval');
        $html = page($p, $page->totalRows, $page_size, 8);
        return array('list' => $list, 'page' => $html, 'star' => $page->firstRow);
        return $this->where($where)->order('add_time desc')->select();
        return $this->order('add_time desc')->select();
    }

    function getInfo($id) {
        return $this->find($id);
    }

    function modify($data, $where) {
        return $this->where($where)->save($data);
    }

    function del($id) {
        $where = array('id' => $id);
        return $this->where($where)->delete();
    }

}
